---
title: "controlling_for_topic"
output: html_document
editor_options: 
  chunk_output_type: console
---

```{r}
rm(list = ls())
library(data.table); library(tidyverse); library(psych); library(fixest); library(marginaleffects);
```

```{r}
d0 <- fread("../data/clean/data-long.csv")
glimpse(d0)
d0 <- d0[veracity != "none"]
# d0 <- d0[screenacc == 1.0]
unique(d0$responseid)
summary(d0)
```

```{r recode}
d0[, table(veracity)]
d0[, veracityc := ifelse(veracity == "false", -0.5, 0.5)]
d0[, table(veracityc)]

d0[, responseid := factor(responseid)]
glimpse(d0)

d0[, condition := factor(condition, levels = c("misinfo-only", "correction-only", "debunk"), 
                         labels = c("base_Misinfo", "Correction", "Debunk"))]


d0[, condition := relevel(condition, "base_Misinfo")]

d0[, condition := as.character(condition)]

d0$belief <- -1
d0[topic == "rust", belief := rust]
d0[topic == "ive", belief := ivermectin]
d0[topic == "asp", belief := aspartame]
d0[topic == "asymp", belief := asymptomatic]
d0[topic == "herd", belief := herd]
d0[topic == "brain", belief := brain]
d0[belief == -1]
dbelief <- select(d0, responseid, topic, condition, belief) |> distinct()
```


```{r}
feols(videorating ~ veracity * condition | topic, d0[condition %in% c("base_Misinfo", "Debunk")], cluster = c("responseid", "topic"))

feols(videorating ~ veracity * condition | topic, d0[condition %in% c("base_Misinfo", "Correction")], cluster = c("responseid", "topic"))

feols(belief ~ condition | topic, d0[condition %in% c("base_Misinfo", "Debunk")], cluster = c("topic"))

feols(belief ~ condition | topic, d0[condition %in% c("base_Misinfo", "Correction")], cluster = c("topic"))
```

```{r}

```

